<html>

<head>
<title>SQL Relay - Getting Started With Firebird</title>
<link rel="stylesheet" href="../css/styles.css">
</head>

<body>

<span class="heading1">Getting Started With Firebird</span><br>

<ul>
<li><a href="#installation">Installation</a></li>
<ul>
<li><a href="#startingatboot">Starting the Database at Boot Time</a></li>
</ul>
<li><a href="#creating">Creating a Database</a></li>
<li><a href="#accessing">Accessing a Database</a></li>
<li><a href="#sqlrelay">Accessing a Database With SQL Relay</a></li>
<li><a href="#quirks">Firebird Quirks</a></li>
</ul>

<a name="installation"></a>
<span class="heading1">Installation</span><br>

<p>I've successfully installed Firebird 1.0.0, 1.0.2, 1.0.3, 1.5, 1.5.2, 1.5.3,
2.0.0rc4 and 2.1 on Linux.  I've never tried to install them on any other
platform.</p>

<p>There are 2 versions of Firebird: Classic Server (CS) and
Super Server (SS).  Classic Server only allows a single connection while Super
Server allows multiple connections.  I recommend using Super Server and this
document describes its installation.</p>

<p>Binary and source distributions of Firebird in many different formats
(including tar.gz and RPM) for many different platforms are available at the
<a href="http://firebird.sourceforge.net">Firebird web site</a>.

<p>The tar.gz distributions come with an install script.  The RPM distributions
can be installed using <i>rpm -i</i>.</p>

<p>Firebird distributions prior to version 1.5
create a directory called /opt/interbase.  Firebird versions 1.5 and higher
create /opt/firebird.</p>

<p>Firebird versions 1.5 and higher rpm's leave /opt/firebird
owned by root,
with -r-xr-xr-x permissions.  This is wrong and will cause the server not to
start.  Change the permissions and ownership as follows (as root):</p>

<blockquote><b>
chmod 775 /opt/firebird<br>
chown firebird:firebird /opt/firebird
</b></blockquote>

<p>Firebird versions 1.5 and higher, below Firebird 2.0 require libstdc++.so.5
but most Linux distributions ship with a more recent version.  If your system
doesn't have /usr/lib/libstdc++.so.5
then you may need to install a compatibility library.  On Fedora Core 4, you
need to install compat-libstdc++-33 as follows (as root):</p>

<blockquote><b>
yum install compat-libstdc++-33
</b></blockquote>

<a name="startingatboot"></a>
<span class="heading2">Starting the Database at Boot Time</span><br>

<p>The package distributions of Firebird install a script which
starts the database at boot time and stops it at shutdown time.  If you
compiled from source, you'll need to install a script like one of the following
to start/stop the database at boot/shutdown time.</p>

<p>For Firebird version 1.5 or higher, use the following script:</p>

<blockquote>
<PRE>
<FONT color=#0000ff>#!/bin/sh</FONT>

<B><FONT color=#a62828>case</FONT></B> &quot;$1&quot; <B><FONT color=#a62828>in</FONT></B>
  start<B><FONT color=#a62828>)</FONT></B>
        su -l firebird <font color="#a52829">"/opt/firebird/bin/fbmgr -start -forever"</font>
        <B><FONT color=#a62828>;;</FONT></B>
  stop<B><FONT color=#a62828>)</FONT></B>
        su -l firebird <font color="#a52829">"/opt/firebird/bin/fbmgr -shut -user sysdba -password changeme"</font>
        <B><FONT color=#a62828>;;</FONT></B>
  *<B><FONT color=#a62828>)</FONT></B>
        <B><FONT color=#a62828>echo</FONT></B><FONT color=#ff00ff> $</FONT><B><FONT color=#a62828>&quot;</FONT></B><FONT color=#ff00ff>Usage: </FONT><FONT color=#a620f7>$0</FONT><FONT color=#ff00ff> {start|stop}</FONT><B><FONT color=#a62828>&quot;</FONT></B>
        <B><FONT color=#a62828>exit</FONT></B> <FONT color=#ff00ff>1</FONT>
<B><FONT color=#a62828>esac</FONT></B>

<B><FONT color=#a62828>exit</FONT></B> <FONT color=#ff00ff>0</FONT>

</PRE>
</blockquote>

<p>For Firebird prior to version 1.5, use the following script:</p>

<blockquote>
<PRE>
<FONT color=#0000ff>#!/bin/sh</FONT>

<B><FONT color=#a62828>case</FONT></B> &quot;$1&quot; <B><FONT color=#a62828>in</FONT></B>
  start<B><FONT color=#a62828>)</FONT></B>
        /opt/interbase/bin/ibmgr -start
        <B><FONT color=#a62828>;;</FONT></B>
  stop<B><FONT color=#a62828>)</FONT></B>
        /opt/interbase/bin/ibmgr -shut -user sysdba -password changeme
        <B><FONT color=#a62828>;;</FONT></B>
  *<B><FONT color=#a62828>)</FONT></B>
        <B><FONT color=#a62828>echo</FONT></B><FONT color=#ff00ff> $</FONT><B><FONT color=#a62828>&quot;</FONT></B><FONT color=#ff00ff>Usage: </FONT><FONT color=#a620f7>$0</FONT><FONT color=#ff00ff> {start|stop}</FONT><B><FONT color=#a62828>&quot;</FONT></B>
        <B><FONT color=#a62828>exit</FONT></B> <FONT color=#ff00ff>1</FONT>
<B><FONT color=#a62828>esac</FONT></B>

<B><FONT color=#a62828>exit</FONT></B> <FONT color=#ff00ff>0</FONT>

</PRE>
</blockquote>

<p>Install this script and run it with the "start" option to start up the
database.  Running it with the "stop" option shuts the database down.  To
access a database, it must be running.</p>

<p>Note that the /etc/hosts.equiv file must contain an entry for localhost and
possibly localhost.localdomain for the database to start properly and for the
"local" tools (such as <i>ibmgr</i>/<i>fbmgr</i> and <i>gsec</i> to
function.</p>

<a name="creating"></a>
<span class="heading1">Creating a Database</span><br>

<p>After installation, Firebird is ready to use but to do any useful
work, you'll have to create a database.</p>

<p>At this point, you should set up your environment.  The Firebird
client is called </i>isql</i>.  Note that <i>unixODBC</i> and <i>Sybase</i>
have a client called <i>isql</i> as well which could be installed in /usr/bin,
/usr/local/bin, /opt/sybase*/bin or some other path.  If you have
<i>unixODBC</i> or <i>Sybase</i> installed, you'll have to decide which client
you want the <i>isql</i> command to run.  If you want it to run the
Firebird client, follow the instructions below.  Otherwise, you'll
have to run the Firebird <i>isql</i> client by its full pathname.</p>

<p>If you are using Firebird prior to version 1.5, in the
configuration script for your shell, add <i>/opt/interbase/bin</i> to your
PATH environment variable.  If you are using Firebird version 1.5 or higher, add
<i>/opt/firebird/bin</i> to your PATH environment variable.  You can add the
paths as follows.</p>

<p>For Bourne shells:</p>

<blockquote>
<PRE>
<FONT color=#008a8e>PATH</FONT>=<FONT color=#a620f7>$PATH</FONT>:/opt/firebird/bin
<B><FONT color=#a62828>export </FONT></B><FONT color=#008a8e>PATH</FONT>
</PRE>
</blockquote>

<p>or</p>

<blockquote>
<PRE>
<FONT color=#008a8e>PATH</FONT>=<FONT color=#a620f7>$PATH</FONT>:/opt/interbase/bin
<B><FONT color=#a62828>export </FONT></B><FONT color=#008a8e>PATH</FONT>
</PRE>
</blockquote>

<p>For C-shells:</p>

<blockquote>
<PRE>
<B><FONT color=#a62828>setenv</FONT></B> <FONT color=#6959cf>PATH</FONT> <B><FONT color=#288a51>${PATH}</FONT></B>:/opt/firebird/bin
</PRE>
</blockquote>

<p>or</p>

<blockquote>
<PRE>
<B><FONT color=#a62828>setenv</FONT></B> <FONT color=#6959cf>PATH</FONT> <B><FONT color=#288a51>${PATH}</FONT></B>:/opt/interbase/bin
</PRE>
</blockquote>

<p>Now log out and log back in and you can access the database using the 
<i>isql</i> client.</p>

<p>Under Firebird 2.0, the installation process creates a security database
called <i>security2.fdb</i> containing host and user privileges and an
administrative user named <i>SYSDBA</i> with a randomly generated password.
This password is listed in <i>SYSDBA.password</i>.</p>

<p>Under Firebird 1.5, the installation process creates a security database
called <i>security.fdb</i> containing host and user privileges and an
administrative user named <i>SYSDBA</i> with a randomly generated password.
This password is listed in <i>SYSDBA.password</i>.</p>

<p>Under Firebird prior to version 1.5, the installation process
creates a security database named <i>isc4.gdb</i> containing host and user
privileges and an administrative user named <i>SYSDBA</i> with a password of
either <i>changeme</i> or <i>masterkey</i>.</p>

<p>Firebird user names are case insensitive and can be up to 31
characters long.  Firebird passwords are case sensitive and can be up
to 32 characters long, but only the first 8 characters are actually used.</p>

<p>Use the <i>gsec</i> utility to change the <i>SYSDBA</i> password to 
<i>newpassword</i> and create a new user named <i>testuser</i> with password 
<i>testpassword</i>.  <i>gsec</i> must be run as root, from the directory 
containing <i>isc4.gdb</i>.  A gsec session follows.</p>

<p>Note that the /etc/hosts.equiv file must contain an entry for localhost and
possibly localhost.localdomain for the <i>gsec</i> to function.</p>

<p>For Firebird verison 2.0 or higher (replace <i>password</i> with the password
in the SYSDBA.password file)...</p>

<blockquote>
<PRE>
<B><FONT color=#a62828>[</FONT></B>root@localhost root<B><FONT color=#a62828>]</FONT></B><FONT color=#0000ff># cd /opt/firebird</FONT>
<B><FONT color=#a62828>[</FONT></B>root@localhost root<B><FONT color=#a62828>]</FONT></B><FONT color=#0000ff># ./bin/changeDBAPassword.sh</FONT>
Please enter current password for SYSDBA user: <i>password</i>
Please enter new password for SYSDBA user: newpassword
GSEC<B><FONT color=#a62828>&gt;</FONT></B> Warning - maxiumum 8 significant bytes of password used
GSEC<B><FONT color=#a62828>&gt;</FONT></B>

Running ex to modify /etc/rc.d/init.d/firebird
<B><FONT color=#a62828>[</FONT></B>root@localhost firebird<B><FONT color=#a62828>]</FONT></B><FONT color=#0000ff># ls -l security2.fdb</FONT>
-rw-rw-rw-    <FONT color=#ff00ff>1</FONT> root     root       <FONT color=#ff00ff>618496</FONT> Feb <FONT color=#ff00ff>18</FONT> <FONT color=#ff00ff>14</FONT>:<FONT color=#ff00ff>29</FONT> security2.fdb
<B><FONT color=#a62828>[</FONT></B>root@localhost firebird<B><FONT color=#a62828>]</FONT></B><FONT color=#0000ff># /opt/firebird/bin/gsec -user SYSDBA -password newpassword</FONT>
GSEC<B><FONT color=#a62828>&gt;</FONT></B> add testuser <FONT color=#6959cf>-pw</FONT> testpassword
Warning - maximum 8 significant bytes of password used
GSEC<B><FONT color=#a62828>&gt;</FONT></B> quit 
</PRE>
</blockquote>

<p>For Firebird verison 1.5 or higher, but below 2.0 (replace <i>password</i>
with the password in the SYSDBA.password file)...</p>

<blockquote>
<PRE>
<B><FONT color=#a62828>[</FONT></B>root@localhost root<B><FONT color=#a62828>]</FONT></B><FONT color=#0000ff># cd /opt/firebird</FONT>
<B><FONT color=#a62828>[</FONT></B>root@localhost root<B><FONT color=#a62828>]</FONT></B><FONT color=#0000ff># ./bin/changeDBAPassword.sh</FONT>
Please enter current password for SYSDBA user: <i>password</i>
Please enter new password for SYSDBA user: newpassword
GSEC<B><FONT color=#a62828>&gt;</FONT></B> Warning - maxiumum 8 significant bytes of password used
GSEC<B><FONT color=#a62828>&gt;</FONT></B>

Running ex to modify /etc/rc.d/init.d/firebird
<B><FONT color=#a62828>[</FONT></B>root@localhost firebird<B><FONT color=#a62828>]</FONT></B><FONT color=#0000ff># ls -l security.fdb</FONT>
-rw-rw-rw-    <FONT color=#ff00ff>1</FONT> root     root       <FONT color=#ff00ff>618496</FONT> Feb <FONT color=#ff00ff>18</FONT> <FONT color=#ff00ff>14</FONT>:<FONT color=#ff00ff>29</FONT> security.fdb
<B><FONT color=#a62828>[</FONT></B>root@localhost firebird<B><FONT color=#a62828>]</FONT></B><FONT color=#0000ff># /opt/firebird/bin/gsec -user SYSDBA -password newpassword</FONT>
GSEC<B><FONT color=#a62828>&gt;</FONT></B> add testuser
GSEC<B><FONT color=#a62828>&gt;</FONT></B> modify testuser <FONT color=#6959cf>-pw</FONT> testpassword
Warning - maximum 8 significant bytes of password used
GSEC<B><FONT color=#a62828>&gt;</FONT></B> quit 
</PRE>
</blockquote>

<p>For Firebird prior to verison 1.5...</p>

<blockquote>
<PRE>
<B><FONT color=#a62828>[</FONT></B>root@localhost root<B><FONT color=#a62828>]</FONT></B><FONT color=#0000ff># cd /opt/interbase</FONT>
<B><FONT color=#a62828>[</FONT></B>root@localhost interbase<B><FONT color=#a62828>]</FONT></B><FONT color=#0000ff># ls -l isc4.gdb</FONT>
-rw-rw-rw-    <FONT color=#ff00ff>1</FONT> root     root       <FONT color=#ff00ff>618496</FONT> Feb <FONT color=#ff00ff>18</FONT> <FONT color=#ff00ff>14</FONT>:<FONT color=#ff00ff>29</FONT> isc4.gdb
<B><FONT color=#a62828>[</FONT></B>root@localhost interbase<B><FONT color=#a62828>]</FONT></B><FONT color=#0000ff># /opt/interbase/bin/gsec</FONT>
GSEC<B><FONT color=#a62828>&gt;</FONT></B> modify sysdba <FONT color=#6959cf>-pw</FONT> newpassword
Warning - maximum 8 significant bytes of password used
GSEC<B><FONT color=#a62828>&gt;</FONT></B> add testuser
GSEC<B><FONT color=#a62828>&gt;</FONT></B> modify testuser <FONT color=#6959cf>-pw</FONT> testpassword
Warning - maximum 8 significant bytes of password used
GSEC<B><FONT color=#a62828>&gt;</FONT></B> quit 
</PRE>
</blockquote>

<p>Now that the <i>SYSDBA</i> password has been changed in the database, you
should update the start/stop script with the new password as well.</p>

<p>Though you can create tables in the <i>isc4.gdb</i> database using the 
SYSDBA user, it's not a good idea.  You should create a new database using a
regular user.  The following sequence of commands creates a database.</p>

<p>For Firebird version 1.5 or higher, these commands create a database called
<i>/opt/firebird/testdb.gdb</i> which is owned by <i>testuser</i>.</p>

<blockquote>
<PRE>
[user@localhost user]$ isql -u testuser -p testpassword
Use CONNECT or CREATE DATABASE to specify a database
SQL&gt; <B><FONT color=#a62828>create</FONT></B> database <FONT color=#ff00ff>'/opt/firebird/testdb.gdb'</FONT>;
SQL&gt; quit;
</PRE>
</blockquote>

<p>For Firebird prior to version 1.5, these commands create a
database called <i>/opt/interbase/testdb.gdb</i> which is owned by
<i>testuser</i>.</p>

<blockquote>
<PRE>
[user@localhost user]$ isql -u testuser -p testpassword
Use CONNECT or CREATE DATABASE to specify a database
SQL&gt; <B><FONT color=#a62828>create</FONT></B> database <FONT color=#ff00ff>'/opt/interbase/testdb.gdb'</FONT>;
SQL&gt; quit;
</PRE>
</blockquote>

<p>Firebird databases are referenced by the pathname of the database
file.  If you try to create a database using a file name that already exists or
if you forget to enclose the file name in single quotes, you'll get a cryptic
error indicating that the 'database' token is unknown.  So, if you get a
message like that, make sure that you enclosed the file name in single quotes
and make sure that the database file that you're trying to create doesn't
already exist.</p>

<p>Now you can log into the database as <i>testuser</i>.</p>

<p>Use the following command for Firebird 1.5 or higher.</p>

<blockquote>
<b>isql -u testuser -p testpassword /opt/firebird/testdb.gdb</b>
</blockquote>

<p>Use the following command for Firebird prior to version 1.5.</p>

<blockquote>
<b>isql -u testuser -p testpassword /opt/interbase/testdb.gdb</b>
</blockquote>

<p>The only users that can drop a database are the user that owns the database 
and the <i>SYSDBA</i> user.  If you want to drop the database, you can do so 
using <i>isql</i> as follows for Firebird version 1.5 or higher...</p>

<blockquote>
<PRE>
[user@localhost user]$ isql -u testuser -p testpassword /opt/firebird/testdb.gdb 
Database:  /opt/firebird/testdb.gdb, User: testuser
SQL&gt; <B><FONT color=#a62828>drop</FONT></B> database;
SQL&gt; quit;
</PRE>
</blockquote>

<p>Or as follows for Firebird prior to version 1.5.</p>

<blockquote>
<PRE>
[user@localhost user]$ isql -u testuser -p testpassword /opt/interbase/testdb.gdb 
Database:  /opt/interbase/testdb.gdb, User: testuser
SQL&gt; <B><FONT color=#a62828>drop</FONT></B> database;
SQL&gt; quit;
</PRE>
</blockquote>

<p>To delete a user, use the <i>gsec</i> utility as the root user and delete 
the appropriate user as follows for Firebird version 1.5 or higher.</p>

<blockquote>
<PRE>
<B><FONT color=#a62828>[</FONT></B>root@localhost root<B><FONT color=#a62828>]</FONT></B><FONT color=#0000ff># cd /opt/firebird</FONT>
<B><FONT color=#a62828>[</FONT></B>root@localhost firebird<B><FONT color=#a62828>]</FONT></B><FONT color=#0000ff># ls -l isc4.gdb</FONT>
-rw-rw-rw-    <FONT color=#ff00ff>1</FONT> root     root       <FONT color=#ff00ff>626688</FONT> Feb <FONT color=#ff00ff>18</FONT> <FONT color=#ff00ff>20</FONT>:<FONT color=#ff00ff>43</FONT> isc4.gdb
<B><FONT color=#a62828>[</FONT></B>root@localhost firebird<B><FONT color=#a62828>]</FONT></B><FONT color=#0000ff># /opt/firebird/bin/gsec</FONT>
GSEC<B><FONT color=#a62828>&gt;</FONT></B> delete testuser
GSEC<B><FONT color=#a62828>&gt;</FONT></B> quit
</PRE>
</blockquote>

<p>Or as follows for Firebird prior to version 1.5.</p>

<blockquote>
<PRE>
<B><FONT color=#a62828>[</FONT></B>root@localhost root<B><FONT color=#a62828>]</FONT></B><FONT color=#0000ff># cd /opt/interbase</FONT>
<B><FONT color=#a62828>[</FONT></B>root@localhost interbase<B><FONT color=#a62828>]</FONT></B><FONT color=#0000ff># ls -l isc4.gdb</FONT>
-rw-rw-rw-    <FONT color=#ff00ff>1</FONT> root     root       <FONT color=#ff00ff>626688</FONT> Feb <FONT color=#ff00ff>18</FONT> <FONT color=#ff00ff>20</FONT>:<FONT color=#ff00ff>43</FONT> isc4.gdb
<B><FONT color=#a62828>[</FONT></B>root@localhost interbase<B><FONT color=#a62828>]</FONT></B><FONT color=#0000ff># /opt/interbase/bin/gsec</FONT>
GSEC<B><FONT color=#a62828>&gt;</FONT></B> delete testuser
GSEC<B><FONT color=#a62828>&gt;</FONT></B> quit
</PRE>
</blockquote>

<p>This should be enough to get you started.  To set up more complex 
configurations, consult the 
<a href="http://firebird.sourceforge.net/index.php?op=doc">Firebird documentation</a>.</p>

<a name="accessing"></a>
<span class="heading1">Accessing a Database</span><br>

<p>To access a database called <i>/opt/firebird/testdb.gdb</i> on the local
machine as the <i>testuser</i> user with password <i>testpassword</i>, use the
following command.</p>

<blockquote>
<b>isql -u testuser -p testpassword /opt/firebird/testdb.gdb</b>
</blockquote>

<p>To connect to a database on a remote machine, prepend the database
filename with the remote hostname, followed by a colon.  For example, to access 
a database called <i>/opt/firebird/testdb.gdb</i> on the remote machine 
<i>testhost</i> as the <i>testuser</i> user with password <i>testpassword</i>, 
use the following command.</p>

<blockquote>
<b>isql -u testuser -p testpassword testhost:/opt/firebird/testdb.gdb</b>
</blockquote>

<p>Once you're connected to the database, the isql client prompts you to enter
a query.  Queries may be split across multiple lines.  To run a query, 
end it with a semicolon.  To exit, type quit;.</p>

<p>A sample <i>isql</i> session follows.</p>

<blockquote>
<PRE>
[user@localhost user]$ isql -u testuser -p testpass /opt/firebird/testdb.gdb
Database:  /opt/firebird/testdb.gdb, <FONT color=#6959cf>User</FONT>: testuser
SQL&gt; <B><FONT color=#a62828>create</FONT></B> <FONT color=#6959cf>table</FONT> testtable (
CON&gt; col1 <B><FONT color=#288a51>char</FONT></B>(<FONT color=#ff00ff>40</FONT>),
CON&gt; col2 integer
CON&gt; );
SQL&gt; show <FONT color=#6959cf>table</FONT> testtable;
COL1                            <B><FONT color=#288a51>CHAR</FONT></B>(<FONT color=#ff00ff>40</FONT>) Nullable 
COL2                            <B><FONT color=#288a51>INTEGER</FONT></B> Nullable 
SQL&gt; <B><FONT color=#a62828>insert</FONT></B> <FONT color=#6959cf>into</FONT> testtable <FONT color=#6959cf>values</FONT> (<FONT color=#ff00ff>'hello'</FONT>,<FONT color=#ff00ff>50</FONT>);
SQL&gt; <B><FONT color=#a62828>insert</FONT></B> <FONT color=#6959cf>into</FONT> testtable <FONT color=#6959cf>values</FONT> (<FONT color=#ff00ff>'hi'</FONT>,<FONT color=#ff00ff>60</FONT>);
SQL&gt; <B><FONT color=#a62828>insert</FONT></B> <FONT color=#6959cf>into</FONT> testtable <FONT color=#6959cf>values</FONT> (<FONT color=#ff00ff>'bye'</FONT>,<FONT color=#ff00ff>70</FONT>);
SQL&gt; <B><FONT color=#a62828>select</FONT></B> * <FONT color=#6959cf>from</FONT> testtable;

COL1                                             COL2 
======================================== ============ 

hello                                              <FONT color=#ff00ff>50</FONT> 
hi                                                 <FONT color=#ff00ff>60</FONT> 
bye                                                <FONT color=#ff00ff>70</FONT> 

SQL&gt; <B><FONT color=#a62828>update</FONT></B> testtable <B><FONT color=#a62828>set</FONT></B> col2=<FONT color=#ff00ff>0</FONT> <FONT color=#6959cf>where</FONT> col1=<FONT color=#ff00ff>'hi'</FONT>;
SQL&gt; <B><FONT color=#a62828>select</FONT></B> * <FONT color=#6959cf>from</FONT> testtable;

COL1                                             COL2 
======================================== ============ 

hello                                              <FONT color=#ff00ff>50</FONT> 
hi                                                  <FONT color=#ff00ff>0</FONT> 
bye                                                <FONT color=#ff00ff>70</FONT> 

SQL&gt; <B><FONT color=#a62828>delete</FONT></B> <FONT color=#6959cf>from</FONT> testtable <FONT color=#6959cf>where</FONT> col2=<FONT color=#ff00ff>50</FONT>;
SQL&gt; <B><FONT color=#a62828>select</FONT></B> * <FONT color=#6959cf>from</FONT> testtable;

COL1                                             COL2 
======================================== ============ 

hi                                                  <FONT color=#ff00ff>0</FONT> 
bye                                                <FONT color=#ff00ff>70</FONT> 

SQL&gt; <B><FONT color=#a62828>commit</FONT></B>;
SQL&gt; <B><FONT color=#a62828>drop</FONT></B> <FONT color=#6959cf>table</FONT> testtable;
SQL&gt; quit;
</PRE>
</blockquote>

<a name="sqlrelay"></a>
<span class="heading1">Accessing a Database With SQL Relay</span><br>

<p>Accessing Firebird from SQL Relay requires an instance entry in
your <i>sqlrelay.conf</i> file for the database that you want 
to access.  Here is an example <i>sqlrelay.conf</i> which defines an SQL Relay 
instance called firebirdtest.  This instance connects to the 
<i>/opt/firebird/testdb</i> database as the user <i>testuser</i> with password 
<i>testpassword</i>.</p>

<PRE>
<FONT color=#0000ff>&lt;?</FONT><B><FONT color=#288a51>xml version=</FONT></B><FONT color=#ff00ff>&quot;1.0&quot;</FONT><FONT color=#0000ff>?&gt;</FONT>
<FONT color=#008a8e>&lt;!</FONT><B><FONT color=#a62828>DOCTYPE</FONT></B> instances <B><FONT color=#a62828>SYSTEM</FONT></B> <FONT color=#ff00ff>&quot;sqlrelay.dtd&quot;</FONT><FONT color=#008a8e>&gt;</FONT>
<FONT color=#008a8e>&lt;instances&gt;</FONT>

        <FONT color=#008a8e>&lt;instance id=</FONT><FONT color=#ff00ff>&quot;firebirdtest&quot;</FONT><FONT color=#008a8e> port=</FONT><FONT color=#ff00ff>&quot;9000&quot;</FONT><FONT color=#008a8e> socket=</FONT><FONT color=#ff00ff>&quot;/tmp/firebirdtest.socket&quot;</FONT><FONT color=#008a8e> dbase=</FONT><FONT color=#ff00ff>&quot;firebird&quot;</FONT><FONT color=#008a8e> connections=</FONT><FONT color=#ff00ff>&quot;3&quot;</FONT><FONT color=#008a8e> maxconnections=</FONT><FONT color=#ff00ff>&quot;5&quot;</FONT><FONT color=#008a8e> maxqueuelength=</FONT><FONT color=#ff00ff>&quot;0&quot;</FONT><FONT color=#008a8e> growby=</FONT><FONT color=#ff00ff>&quot;1&quot;</FONT><FONT color=#008a8e> ttl=</FONT><FONT color=#ff00ff>&quot;60&quot;</FONT><FONT color=#008a8e> endofsession=</FONT><FONT color=#ff00ff>&quot;commit&quot;</FONT><FONT color=#008a8e> sessiontimeout=</FONT><FONT color=#ff00ff>&quot;600&quot;</FONT><FONT color=#008a8e> runasuser=</FONT><FONT color=#ff00ff>&quot;nobody&quot;</FONT><FONT color=#008a8e> runasgroup=</FONT><FONT color=#ff00ff>&quot;nobody&quot;</FONT><FONT color=#008a8e> cursors=</FONT><FONT color=#ff00ff>&quot;5&quot;</FONT><FONT color=#008a8e> authtier=</FONT><FONT color=#ff00ff>&quot;listener&quot;</FONT><FONT color=#008a8e> handoff=</FONT><FONT color=#ff00ff>&quot;pass&quot;</FONT><FONT color=#008a8e>&gt;</FONT>
                <FONT color=#008a8e>&lt;users&gt;</FONT>
                        <FONT color=#008a8e>&lt;user user=</FONT><FONT color=#ff00ff>&quot;firebirdtest&quot;</FONT><FONT color=#008a8e> password=</FONT><FONT color=#ff00ff>&quot;firebirdtest&quot;</FONT><FONT color=#008a8e>/&gt;</FONT>
                <FONT color=#008a8e>&lt;/users&gt;</FONT>
                <FONT color=#008a8e>&lt;connections&gt;</FONT>
                        <FONT color=#008a8e>&lt;connection connectionid=</FONT><FONT color=#ff00ff>&quot;firebirdtest&quot;</FONT><FONT color=#008a8e> string=</FONT><FONT color=#ff00ff>&quot;user=testuser;password=testpassword;database=/opt/firebird/testdb.gdb;dialect=3&quot;</FONT><FONT color=#008a8e> metric=</FONT><FONT color=#ff00ff>&quot;1&quot;</FONT><FONT color=#008a8e>/&gt;</FONT>
                <FONT color=#008a8e>&lt;/connections&gt;</FONT>
        <FONT color=#008a8e>&lt;/instance&gt;</FONT>

<FONT color=#008a8e>&lt;/instances&gt;</FONT>
</PRE>

<p>Note that in this example, the database parameter of the string attribute in
the connection tag references the local database
<i>/opt/firebird/testdb.gdb</i>.
If you want to access a remote database, prepend the database filename with
the remote hostname followed by a colon.  For example: 
<i>testhost:/opt/firebird/testdb.gdb</i>.</p>

<p>Now you can start up this instance with the following command.</p>

<blockquote>
<b>sqlr-start -id firebirdtest</b>
</blockquote>

<p>To connect to the instance and run queries, use the following command.</p>

<blockquote>
<b>sqlrsh -id firebirdtest</b>
</blockquote>

<p>The following command shuts down the SQL Relay instance.</p>

<blockquote>
<b>sqlr-stop firebirdtest</b>
</blockquote>

<a name="quirks"></a>
<span class="heading1">Firebird Quirks</span><br>

<p>In most databases, you can create, alter or drop databse objects such as
tables, indices or stored procedures at will.  In Firebird, you
should create, alter or drop databse objects when you have exclusive access
to the databse.</p>

<p>Basically, you should shut down SQL Relay or any other clients,
use isql to create, alter or drop the objects, then start SQL Relay again.
If you don't do this, you'll get confusing results.</p>

</body>

</html>
